from common.httpRequest import Webrequests


# 商家web端登录
class LoginForWebCompany:
    def __init__(self, mobile, password, appKey='QTSHE_WEB', sign='c114dc3571aaad3cf6bbf99ce18fd0ba', version='4.7.0', timestamp='1547798318463', deviceId='0.6242260541105884'):
        self.mobile = mobile
        self.password = password
        self.appKey = appKey
        self.sign = sign
        self.version = version
        self.timestamp = timestamp
        self.deviceId =deviceId


    def do_login(self):
        url = "https://test-api.qtshe.com:443/companyCenter/companyAccountWeb/login"
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        param = {'appKey': str(self.appKey), 'sign': str(self.sign), 'version': str(self.version), 'timestamp': str(self.timestamp), 'deviceId': str(self.deviceId), 'mobile': str(self.mobile), 'password': str(self.password)}
        try:
           r = Webrequests(url, param, headers).post()
           if r.status_code == 200:
               print("登录成功")
               print("登录参数:"+str(param))
               return r
        except Exception as e:
            print("登录失败")

if __name__ == '__main__':
    login = LoginForWebCompany("12222222222","q123456")
    login.do_login()


